﻿Imports Microsoft.TeamFoundation.WorkItemTracking.Client

Public Class WorkItemSummeryControl

    Private m_Project As Project

    Public ReadOnly Property Project() As Project
        Get
            Return m_Project
        End Get
    End Property

    Private m_Node As Node

    Public ReadOnly Property Node() As Node
        Get
            Return m_Node
        End Get
    End Property

    Private m_WorkItem As WorkItem

    Public ReadOnly Property WorkItem() As WorkItem
        Get
            Return m_WorkItem
        End Get
    End Property

    Public Sub SetValues(ByVal Project As Project, ByVal Node As Node, ByVal WorkItem As WorkItem)
        m_Project = Project
        m_Node = Node
        m_WorkItem = WorkItem
        Refresh()
    End Sub

    Public Shadows Sub Refresh()
        Dim WICount As Integer = 0
        Me.ux_GroupBox.Text = String.Format("Summary: {0} WorkItem{1}", 0, IIf(((WICount > 0) Or (WICount = 0)), "'s", ""))
        Me.ux_FlowLayoutPanel.Controls.Clear()
        For Each wit As WorkItemType In Project.WorkItemTypes
            Dim witCount As Integer = 0
            Me.ux_FlowLayoutPanel.Controls.Add(Getlabel(String.Format("{0}: {1}", wit.Name, witCount)))
        Next
        '-------------
        MyBase.Refresh()
    End Sub

    Private Function Getlabel(ByVal ValueToDisplay As String) As Label
        Dim ux_lbl As New Label
        ux_lbl.Text = ValueToDisplay
        ux_lbl.AutoSize = True
        Return ux_lbl
    End Function

End Class
